/*
 * MainForm.java
 *
 * Created on 24 marzec 2007, 14:35
 */
package client;

import datechooser.DateChooserControl;
import daychooser.*;
import java.awt.Color;
import java.awt.Component;
import java.util.Date;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

/**
 *
 * @author  Przemek
 */
public class MainFrame extends javax.swing.JFrame
{
    private Component centerWindow;
    
    /** Creates new form MainForm */
    public MainFrame()
    {
        initComponents();
        //testingDayChooser();
        //testingDateChooser();
        
        this.setSize( 800, 600 );
    }
    
    private void testingControl()
    {
        this.setSize( 640, 480 );
        
        DaysChooserControl ctrl = new DaysChooserControl( new Date( 2007 - 1900, 1, 15 ), new Date( 2007 - 1900, 2, 10 ) );
        
        ctrl.setBorder( new BevelBorder( BevelBorder.RAISED ));
        
        ctrl.setBackground( Color.WHITE );
        ctrl.setForeground( Color.GREEN );
        
        ctrl.setSize( 600, 40 );
        ctrl.setLocation( 20, 20 );
        
        ctrl.setVisible( true);
        ctrl.setEnabled( true );
        
        ctrl.setSelectedDays( new Date[] { new Date( 2007 - 1900, 1, 21 ) } );
        
        ctrl.addFieldSelectingListener( new IFieldSelectingListener()
        {
            public void fieldSelecting(FieldSelectingEvent e)
            {
                if( e.getFieldNo() % 2 == 0 )
                {
                    e.setSelectable( false);
                }
            }
        });
        
        
        daychooser.DaysLabelControl ctrl2 = new daychooser.DaysLabelControl( new Date( 2007 - 1900, 1, 15 ), new Date( 2007 - 1900, 2, 10 ) );
        ctrl2.setBackground( Color.YELLOW );
        ctrl2.setSize( 1000, 60 );
        ctrl2.setLocation( 20, 100 );
        ctrl2.setLabels( new String[] { "raz raz raz", "", "trzy", "cztery" } );
        
        
        
        this.getContentPane().setLayout( null );
        this.add( ctrl );
        this.add( ctrl2 );
        this.doLayout();
        
    }
    
    private void testingDateChooser()
    {
        DateChooserControl ctrl = new DateChooserControl( new Date( 2007 - 1900, 1, 15 ) );
        
        ctrl.setSize( 150, 30 );
        ctrl.setLocation( 20, 20 );
        
        this.getContentPane().setLayout( null );
        this.add( ctrl );        
        this.doLayout();
    }
    
    private void setCenterWindow( Component c )
    {
        if( centerWindow != null )
        {
            this.getContentPane().remove( centerWindow );
        }
        centerWindow = c;
        getContentPane().add( c, java.awt.BorderLayout.CENTER );                
        this.validate();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanelMenu = new javax.swing.JPanel();
        jButtonTeams = new javax.swing.JButton();
        jButtonEmployees = new javax.swing.JButton();
        jButtonVacations = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(640, 480));
        jPanelMenu.setLayout(new java.awt.GridBagLayout());

        jButtonTeams.setText("Teams");
        jButtonTeams.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButtonTeamsActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.weightx = 1.0;
        jPanelMenu.add(jButtonTeams, gridBagConstraints);

        jButtonEmployees.setText("Employees");
        jButtonEmployees.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButtonEmployeesActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.weightx = 1.0;
        jPanelMenu.add(jButtonEmployees, gridBagConstraints);

        jButtonVacations.setText("Vacations");
        jButtonVacations.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButtonVacationsActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.weightx = 1.0;
        jPanelMenu.add(jButtonVacations, gridBagConstraints);

        getContentPane().add(jPanelMenu, java.awt.BorderLayout.NORTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonVacationsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonVacationsActionPerformed
    {//GEN-HEADEREND:event_jButtonVacationsActionPerformed
        setCenterWindow( new VacationsPanel() );
    }//GEN-LAST:event_jButtonVacationsActionPerformed

    private void jButtonEmployeesActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonEmployeesActionPerformed
    {//GEN-HEADEREND:event_jButtonEmployeesActionPerformed
        setCenterWindow( new EmployeesPanel() );
    }//GEN-LAST:event_jButtonEmployeesActionPerformed

    private void jButtonTeamsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonTeamsActionPerformed
    {//GEN-HEADEREND:event_jButtonTeamsActionPerformed
        setCenterWindow( new TeamsPanel() );
    }//GEN-LAST:event_jButtonTeamsActionPerformed
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[])
    {
        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                new MainFrame().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonEmployees;
    private javax.swing.JButton jButtonTeams;
    private javax.swing.JButton jButtonVacations;
    private javax.swing.JPanel jPanelMenu;
    // End of variables declaration//GEN-END:variables
    
}
